<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org" lang="en">
<head>
    <meta charset="UTF-8">
    <title>Current Task</title>
    <span th:include="common/templates :: common-css-js"></span>
    <span th:include="common/templates :: init-menu"></span>
    <span th:include="common/templates :: bootstrap-table"></span>
</head>
<body>
<div th:replace="common/templates :: header"></div>
<div class="container">

    <div class="page-header">
        <div class="h3">CURRENT TASK</div>
    </div>
    <table id="records-info"></table>
</div>
</body>
<script th:inline="text">
    $('#records-info').bootstrapTable({
        url: "[[@{/Task/current}]]",//请求数据url
        showRefresh: true,
        smartDisplay: true,
        showToggle: true,
        paginationPreText: '上一页',
        paginationNextText: '下一页',
        pagination: true,//分页
        pageNumber: 1,
        pageSize: 15,
        pageList: [10, 20, 30, 50, 'all'],//分页步进值
        search: true, //显示搜索框
        columns: [
            {
                field: 'id',
                title: '任务ID',
                sortable: true
            },
            {
                field: 'businessKey',
                title: '业务Key',
            },
            {
                field: 'processDefinitionName',
                title: '流程名',
            },
            {
                field: 'taskName',
                title: '任务名',
            },
            {
                field: 'assignerNames',
                title: '任务审核人',
//                formatter: function (value, row, index) { // 单元格格式化函数
//
//                    var str = "";
//
//                    for (var i = 0; i < value.length; i++) {
//                        str += value[i];
//                        if (i < value.length - 1) {
//                            str += " ，"
//                        }
//                    }
//                    return str;
//                }
            },
            {
                field: 'duration',
                title: '历时',
                formatter: function (value, row, index) { // 单元格格式化函数
                    return value + " 天";
                }
            },
            {
                field: 'createTime',
                title: '时间',
            },
            {
                field: 'id',
                title: '详情',
                formatter: function (value, row, index) { // 单元格格式化函数
                    var str = "";
                    var processDefinitionKey = row['processDefinitionKey'];
                    var step = row['taskDefinitionKey'];
                    if(processDefinitionKey == 'Entity2Process'){
                        str = "<a class='btn btn-default' target='_blank' href='[[@{/view/WorkFlow/Entity2Process/}]]" + value + "' ><i class='glyphicon glyphicon-file'></i></a>";
                    }else{
                        str = "<a class='btn btn-default' target='_blank' href='[[@{/view/WorkFlow/}]]" + processDefinitionKey + "/" + step + "/" + value + "' ><i class='glyphicon glyphicon-file'></i></a>";
                    }

                    return str;
                }
            },
        ]
    })
</script>
</html>